<script lang="ts" setup>
import { ref } from 'vue';
import type { FormInstance } from '@arco-design/web-vue/es/form';

const props = defineProps({
  id: {
    type: [String, Number],
    default: '',
  },
  content: {
    type: String,
    default: '',
  },
});

const formData = ref({
  content: props.content,
});
const formRef = ref<FormInstance>();

const dialogClickButton = async (button: string) => {
  if (button !== 'ok') {
    return;
  }

  const res = await formRef.value?.validate();

  if (res) {
    return false;
  }

  return {
    close: true,
    content: formData.value.content,
  };
}

defineExpose({
  dialogClickButton,
});
</script>

<template>
  <AForm ref="formRef" auto-label-width scroll-to-first-error :model="formData">
    <AFormItem field="content" :label="$t('settings.view.general.addFooter.column1')" :rules="[{ required: true, message: $t('settings.notification.required') }]">
      <AInput v-model="formData.content" :max-length="100" allow-clear show-word-limit />
    </AFormItem>
  </AForm>
</template>

<style lang="scss" scoped>
</style>
